//package xcmg.device.web.wechat;
//
//import io.swagger.annotations.ApiOperation;
//import org.json.JSONException;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.multipart.MultipartFile;
//import xcmg.device.infra.BasicController;
//import xcmg.device.infra.ErrorCode;
//import xcmg.device.infra.FileUtil;
//import xcmg.device.infra.exception.CommonBusiExceptions;
//import xcmg.device.service.barcode.BarcodeService;
//import xcmg.device.service.vo.MaterialClassVO;
//import xcmg.device.service.vo.barcode.BarCodeCheckView;
//import xcmg.device.service.vo.wechat.MaterialsInfoSearchVO;
//import xcmg.device.service.vo.wechat.StoreSearchParam;
//import xcmg.device.service.wechat.WechatService;
//import xcmg.device.service.wechat.xgwjwcf.UserAccessService;
//import yb.ecp.fast.infra.annotation.FastMappingInfo;
//import yb.ecp.fast.infra.infra.ActionResult;
//import yb.ecp.fast.infra.infra.SearchCommonVO;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.List;
//
//@RestController
//@RequestMapping("/wechat")
//public class WechatController extends BasicController {
//
//    @Autowired
//    private HttpServletRequest request;
//
//    @Autowired
//    private WechatService wechatService;
//
//    @Autowired
//    private UserAccessService userAccessService;
//
//    @Autowired
//    private BarcodeService barcodeService;
//
//    @RequestMapping(value = "/getSignData",method = RequestMethod.GET)
//    public ActionResult getSignData(String signUrl) throws JSONException {
//       return actionResult(wechatService.getSignData(signUrl)) ;
//    }
//
//    @RequestMapping(value = "/guidePriceQuery",method = RequestMethod.POST)
//    public ActionResult guidePriceQuery(@RequestBody SearchCommonVO<MaterialsInfoSearchVO> condition){
//        return actionResult(wechatService.guidePriceQuery(condition));
//    }
//
//    @RequestMapping(value = "/materialClassList",method = RequestMethod.GET)
//    public ActionResult materialClassList(MaterialClassVO materialClassVO){
//        List<MaterialClassVO> result=wechatService.materialClassList(materialClassVO);
//        return actionResult(result);
//    }
//
//    @RequestMapping(value = "/getNearbyStore",method = RequestMethod.GET)
//    public ActionResult getNearbyStore(double longitude, double latitude){
//        return actionResult(wechatService.getNearbyStore(longitude,latitude));
//    }
//
//    @RequestMapping(value = "/getStorefrontByArea",method = RequestMethod.GET)
//    public ActionResult getStorefrontByArea(StoreSearchParam storeSearchParam){
//        return actionResult(wechatService.getStorefrontByArea(storeSearchParam));
//    }
//
//    @RequestMapping(value = "/materialsSearch",method = RequestMethod.POST)
//    public ActionResult materialsSearch(@RequestBody MaterialsInfoSearchVO searchVO){
//        return actionResult(wechatService.materialsSearch(searchVO));
//    }
//
//    @RequestMapping(value = "/listMaterialsByOrg",method = RequestMethod.POST)
//    public ActionResult listMaterialsByOrg(@RequestBody SearchCommonVO<MaterialsInfoSearchVO> condition) {
//        return actionResult(wechatService.listMaterialsByCompany(condition));
//    }
//
//    @RequestMapping(value = "/getRegisterInfo",method = RequestMethod.GET)
//    @ApiOperation(value = "验证微信用户的注册信息")
//    public ActionResult getUserRegisterInfo(String code) throws Exception {
//        return actionResult(userAccessService.getUserRegisterInfo(code));
//    }
//
//
//    @RequestMapping(value = "/listFileCategorys",method = RequestMethod.GET)
//    @ApiOperation(value = "获取分类数据")
//    public ActionResult listFileCategorys(){
//        return actionResult(wechatService.listFileCategorys());
//    }
//
//    @ResponseBody
//    @RequestMapping(value = "/uploadAttachs", method = RequestMethod.POST)
//    @FastMappingInfo(needLogin = true)
//    @ApiOperation(value = "上传附件")
//    public ActionResult uploadAttachs(HttpServletRequest request) {
//        try {
//            List<MultipartFile> files = FileUtil.analysisMultFilesByRequest(request);
//
//            wechatService.batchSave(files, Short.valueOf(request.getParameter("fileType")), getUserId(), getOrgId());
//
//        } catch (Exception e) {
//            return new ActionResult(ErrorCode.Failure.getCode(), e.getMessage());
//        }
//        return actionResult(ErrorCode.Success);
//    }
//
//    @RequestMapping(value = "/deleteDoc", method = RequestMethod.GET)
//    @FastMappingInfo(needLogin = true)
//    @ApiOperation(value = "删除文档")
//    public ActionResult deleteDoc(String id) {
//        try {
//            wechatService.deleteAttachment(id);
//        } catch (Exception e) {
//            return new ActionResult(ErrorCode.Failure.getCode(), e.getMessage());
//        }
//        return actionResult(ErrorCode.Success);
//    }
//
//    @RequestMapping(value = "/listAttachmentsByType", method = RequestMethod.GET)
//    @ApiOperation(value = "获取文件信息")
//    public ActionResult listAttachmentsByType(Short fileType) throws Exception {
//      return actionResult(wechatService.listAttachmentsByType(fileType));
//    }
//
//    @RequestMapping(value = "/downloadAttach", method = RequestMethod.GET)
//    @ApiOperation(value = "单个附件信息下载")
//    public void downloadAttach(@RequestParam("id") String id) throws Exception {
//      wechatService.downloadAttach(id);
//    }
//
//    @RequestMapping(value = "/barCodeCheck", method = RequestMethod.GET)
//    @ApiOperation(value = "微信端查看条码真伪")
//    public ActionResult<BarCodeCheckView> barCodeCheck(@RequestParam(value = "barCode", required = true) String barCode) {
//        String site = request.getHeader("x-from-site");
//        if (!"20".equals(site)) {
//            throw new CommonBusiExceptions("该接口为微信端查询接口");
//        }
//        String userId = getUserId();
//        BarCodeCheckView result = barcodeService.queryBarCodeCheck(barCode, userId, true);
//        return actionResult(result);
//    }
//}